<?php

$d = ($edit) ? $module->pages_get($edit) : false;
$n = ($edit) ? $module->getNavFromPageId($d['id']) : false;
$ns = $module->numSkins();

$skinValue = ($d) ? stripslashes($d['skin_id']) : false;

// @todo: a page can have multiple navigations!

?>

<h1 class="<?php echo ($add) ? 'add' : 'edit'; ?>"><?php echo ($add) ? $lang->get('add-page') : $lang->get('edit-page'); ?></h1>

<form name="frm" method="post" action="<?php echo $cosa->system('base-url'); ?>/?m=<?php echo $m; ?>&s=<?php echo $s; ?>">
<input type="hidden" name="<?php echo ($add) ? 'add' : 'edit'; ?>" value="<?php echo ($add) ? '1' : $d['id']; ?>" />
<?php if($n) { ?><input type="hidden" name="nid" value="<?php echo $n['id']; ?>" /><?php } ?>
<?php if($ns == 1) $module->printSkinsDropdown('skin_id', $skinValue); ?>
<ul>
	<li><ul>
			<li><label for="title"><?php $lang->put('system-name'); ?></label>
				<input type="text" name="title" value="<?php if($d) echo stripslashes($d['title']); ?>" class="fld" />
			</li>
			<li><label for="title"><?php $lang->put('url-path'); ?></label>
				<input type="text" name="title" value="<?php if($d) echo stripslashes($d['title']); ?>" class="fld" />
			</li>
		</ul>
	</li>
	<li><ul>
			<li><label for="title"><?php $lang->put('page-title'); ?></label>
				<input type="text" name="title" value="<?php if($d) echo stripslashes($d['title']); ?>" class="fld" />
			</li>
			<li><label for="title"><?php $lang->put('page-text'); ?></label>
				<textarea name="text"><?php if($d) echo stripslashes($d['text']); ?></textarea>
			</li>
		</ul>
	</li>
	<li><a href="#" class="toggleNext<?php if($n) echo ' open'; ?>"><?php $lang->put('navigation'); ?></a>
		<ul style="margin-top:10px;">
			<li><label for="nav_title"><?php $lang->put('nav-title'); ?></label>
				<input type="text" name="nav_title" value="<?php if($n) echo stripslashes($n['title']); ?>" class="fld" />
			</li>
			<li><label for="nav_parent_id"><?php $lang->put('nav-parent-id'); ?></label>
				<?php
				$parent_id = ($n) ? $n['parent_id'] : false;
				$excl_id = ($n) ? $n['id'] : false;
				$module->printNavDropdown('nav_parent_id', $parent_id, $excl_id);
				?>
			</li>
			<li><label for="nav_weight"><?php $lang->put('nav-weight'); ?></label>
				<input type="text" name="nav_weight" value="<?php if($n) echo stripslashes($n['weight']); ?>" class="fld small" />
			</li>
		</ul>
	</li>
	<li><a href="#" class="toggleNext<?php if($n) echo ' open'; ?>"><?php $lang->put('meta-data'); ?></a>
		<ul style="margin-top:10px;">
			<li><label for="meta_title"><?php $lang->put('meta-title'); ?></label>
				<input type="text" name="meta_title" value="<?php if($n) echo stripslashes($n['meta_title']); ?>" class="fld" />
			</li>
			<li><label for="meta_keywords"><?php $lang->put('meta-keywords'); ?></label>
				<input type="text" name="meta_keywords" value="<?php if($n) echo stripslashes($n['meta_keywords']); ?>" class="fld" />
			</li>
			<li><label for="meta_description"><?php $lang->put('meta-description'); ?></label>
				<input type="text" name="meta_description" value="<?php if($n) echo stripslashes($n['meta_description']); ?>" class="fld" />
			</li>
		</ul>
	</li>
	<?php
	
	if($ns > 1) {
		?>
		<li><label for="skin"><?php $lang->put('page-skin'); ?></label>
			<?php $module->printSkinsDropdown('skin_id', $skinValue); ?>
		</li>
		<?php
	}
	
	?>
	<li class="sbmt">
		<input type="submit" value="<?php $lang->put('submit'); ?>" class="sbmt" />
		<?php if($d) $module->printDelLink($d['id'], false, $lang->get('del-page')); ?>
	</li>
</ul>
</form>
